﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using Newtonsoft.Json;

namespace Tesztelo
{
    public class DreonarLetolto
    {
        public void GetData()
        {
            HttpClient client = new HttpClient();
            client.BaseAddress = new Uri("http://dreonar.hu/");

            // Add an Accept header for JSON format.
            client.DefaultRequestHeaders.Accept.Add(
                new MediaTypeWithQualityHeaderValue("application/json"));

            HttpResponseMessage response = client.GetAsync("index.php?pf=api&data=character&karakter_id=9718&api_key=924cd3ba435b8a9e7f509e5bc4ded83271378120075").Result;

            if (response.IsSuccessStatusCode)
            {
                var karakterString =  response.Content.ReadAsStringAsync().Result;
                karakterString = karakterString.Substring(3, karakterString.Length - 4);
                var root = JsonConvert.DeserializeObject<RootObject>(karakterString);
                var k = root.karakter;
            }
            else
            {
                // some error
            }
        }
    }
}
